// 2014-02-01 Tyrghen
//---------------------------------------------
// Usage:
//  [] call edt_fnc_;
//---------------------------------------------
// Purpose:
// 
// 
// Parameters:
// - 
//
// Returns:
// 
//---------------------------------------------
// Objectif:
// 
//
// Paramètres:
// - 
//
// Renvoie:
// 
//---------------------------------------------

//#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "editor\fn_kamikaze.sqf"
#include <tmf_constants.h>
#include <tmf_macros.h>

TRACE_1("Start",_this);
TMFPROFILERSTART;

private ["_kamikaze","_explosive","_distance","_reliability"];

_explosive = "R_60mm_HE"; // ["R_60mm_HE","Bo_Mk82_MI08"]; an array gives a random type of explosion
_distance = 80;
_reliability = 0.9;
_side = GVAR(side_own);

if (IS_ARRAY(_this)) then {
	DEFAULT_PARAM(_kamikaze,0,objNull);
	DEFAULT_PARAM(_explosive,1,_explosive);
	DEFAULT_PARAM(_distance,2,_distance);
	DEFAULT_PARAM(_reliability,3,_reliability);
	DEFAULT_PARAM(_side,4,_side);
} else {
	_kamikaze = _this;
};

if (!IS_OBJECT(_kamikaze) && !IS_GROUP(_kamikaze)) exitWith {ERROR("Kamikaze is not an object or group")};
if (isNull _kamikaze) exitWith {ERROR("Kamikaze not initialized")};
if (!IS_STRING(_explosive)) exitWith {ERROR("Explosive is not a string")};
if (!IS_SCALAR(_reliability)) exitWith {ERROR("Reliability is not a scalar")};
if (!IS_SIDE(_side)) exitWith {ERROR("Side is not valid")};
if (!isServer && {IS_GROUP(_kamikaze)} && {!(local (leader _kamikaze))}) exitWith { ERROR("Not local or server") };
if (!isServer && {IS_OBJECT(_kamikaze)} && {!(local _kamikaze)}) exitWith { ERROR("Not local or server") };

if (_explosive == "") then { _explosive = "R_60mm_HE"};
if (_reliability < 0.3) then { _reliability = 0.3 };
if (_reliability > 1) then { _reliability = 1 };

_kamikaze = [_kamikaze,_side,_distance,_explosive,_reliability] call FFUNC(kamikaze);

TRACE_1("End",_kamikaze);
TMFPROFILERSTOP;
_kamikaze
